/*
 * The VPE Project
 *
 * ide/AppProcs.cpp
 *
 * Copyright (C) 2009 - Eneias Ramos de Melo.
 */


#include <QForms.hpp>
#include <stdio.h>
#pragma hdrstop

#include "AppProcs.h"
#include "packages.h"
#include "uMainWindow.h"
#include "uProjectOptions.h"

USEFORM("uMainWindow.cpp", MainWindow);
USEFORM("uProjectOptions.cpp", ProjectOptions);

//#include <Dialogs.h>
//#include <Packages.h>
//#include "palette.h"
//#include "lib/packages/list.h"
//#include "project/group.h"
//#include "code_editor.h"


void app_init ();

void app_exit ();


void
vpe_init (int vpe_argc, char **vpe_argv)
{
    printf ("VPE Version 0.0.1\n"
             "Initializing ...\n");
    
    /* Initialize the application */
    app_init ();
    
    /* Parse the rest of the command line arguments to load 
    if (vpe_argc > 0)
    {
	while (vpe_argc--)
	{
	    if (*vpe_argv)
		vpe_file_open (*vpe_argv);
	    
	    vpe_argv++;
	}
    }
    else
    {
	// Create a new project by default.
	vpe_project_new (VPE_PROJECT_TYPE_DEFAULT, FALSE);
    }    */
    
    printf ("Loaded!\n");
}

void
vpe_exit (int status)
{
    printf ("Exiting ...\n");
    
    //vpe_project_group_close ();
    
    app_exit ();
    
    //exit (status);
}


void
app_init ()
{
    /*
     * Load packages first ...
     */
    TPackageList::Init ();
    
    Application->CreateForm (__classid (TMainWindow), &MainWindow);
    Application->CreateForm (__classid (TProjectOptions), &ProjectOptions);
    
    /*
     * Initialize interface ...
     */
    //VPEMainWindow::Init ();
    
    //VPECodeEditor::Init ();
    
    /*
     * Load projects ...
     */
    //VPEProjectGroup::Init ();
    
    /*
     * Create a new application ...
     */
    //ProjectGroup->New ();
    
    //init palette after packages!
    // VPEPalette::Init ();
    
    
    // VPEPaletteDlgNew ()->ShowAll ();
    
    
//#ifdef VPE_ENABLE_MAKE
//    vpe_make_init ();
//#endif
    
    /* Create Windows ... */
    // vpe_main_window_init();
    
    // destroy_splash_window();
}

void
app_exit ()
{
    TPackageList::Free ();
}
